package jjn.kamacoder.case17;

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Objects;
import java.util.Scanner;

/**
 * @author Jjn
 * @since 2023-08-31 11:35
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int i = scanner.nextInt();
            if (i == 0) {
                break;
            }
            int[] pushed = new int[i];
            for (int j = 0; j < i; j++) {
                pushed[j] = j + 1;
            }
            int[] popped = new int[i];
            for (int j = 0; j < i; j++) {
                popped[j] = scanner.nextInt();
            }
            Deque<Integer> deque = new ArrayDeque<>();
            int index = 0;
            for(int n : pushed) {
                deque.offer(n);
                while (!deque.isEmpty() && Objects.equals(deque.peekLast(), popped[index])) {
                    deque.pollLast();
                    index++;
                }
            }
            if (deque.isEmpty()) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}
